package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Slf4j
@Api("店铺操作")
public class ShopController {
    @Resource
    RedisTemplate<String,Object> redisTemplate;
    @ApiOperation("修改店铺状态")
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable Integer status){
        log.info("{}",status);
        redisTemplate.opsForValue().set("SHOP_STATUS",status);
        return Result.success();
    }
    @GetMapping ("/status")
    @ApiOperation("获取店铺状态")
    public Result getStatus(){
        log.info("获取店铺状态");
       Integer shopStatus = (Integer)redisTemplate.opsForValue().get("SHOP_STATUS");
        return Result.success(shopStatus);
    }
}
